package com.ruoyi.project.erp.member.service.impl;

import java.util.List;

import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.project.erp.member.mapper.ErpMemberMapper;
import com.ruoyi.project.erp.member.domain.ErpMember;
import com.ruoyi.project.erp.member.service.IErpMemberService;
import com.ruoyi.common.utils.text.Convert;

/**
 * 会员Service业务层处理
 *
 * @author ruoyi
 * @date 2021-08-08
 */
@Service
public class ErpMemberServiceImpl implements IErpMemberService {
    @Autowired
    private ErpMemberMapper erpMemberMapper;

    /**
     * 查询会员
     *
     * @param memberOpenId 会员主键
     * @return 会员
     */
    @Override
    public ErpMember selectErpMemberByMemberOpenId(String memberOpenId) {
        return erpMemberMapper.selectErpMemberByMemberOpenId(memberOpenId);
    }

    @Override
    public ErpMember selectMemberById(Long memberId) {
        return erpMemberMapper.selectMemberById(memberId);
    }

    /**
     * 查询会员列表
     *
     * @param erpMember 会员
     * @return 会员
     */
    @Override
    public List<ErpMember> selectErpMemberList(ErpMember erpMember) {
        return erpMemberMapper.selectErpMemberList(erpMember);
    }

    /**
     * 新增会员l
     *
     * @param erpMember 会员
     * @return 结果
     */
    @Override
    public int insertErpMember(ErpMember erpMember) {
        erpMember.setCreateTime(DateUtils.getNowDate());
        return erpMemberMapper.insertErpMember(erpMember);
    }

    /**
     * 修改会员
     *
     * @param erpMember 会员
     * @return 结果
     */
    @Override
    public int updateErpMember(ErpMember erpMember) {
        erpMember.setUpdateTime(DateUtils.getNowDate());
        return erpMemberMapper.updateErpMember(erpMember);
    }

    /**
     * 批量删除会员
     *
     * @param memberOpenIds 需要删除的会员主键
     * @return 结果
     */
    @Override
    public int deleteErpMemberByMemberOpenIds(String memberOpenIds) {
        return erpMemberMapper.deleteErpMemberByMemberOpenIds(Convert.toStrArray(memberOpenIds));
    }

    /**
     * 删除会员信息
     *
     * @param memberOpenId 会员主键
     * @return 结果
     */
    @Override
    public int deleteErpMemberByMemberOpenId(String memberOpenId) {
        return erpMemberMapper.deleteErpMemberByMemberOpenId(memberOpenId);
    }
}
